Getting Data Out of a Descriptor List
You can use the AECountItems function to count the number of items in a The Open Documents event contains a direct parameter that specifies the list of documents to open. The list of documents is contained in a
you can determine the number of items in the list and then extract each
descriptor record from the descriptor list.
For example, when your handler receives an Open Documents event, you can
descriptor records in the list.
long itemsInList;
& docList);
number of items in the list in the second parameter. When extracting the
descriptor records from a list, you often use the number of items as a loop
index. Here's an example:
for (index = 1; index <= itemsInList; index++) {
//for each descriptor record in the list, get its data
}
The format of the descriptor records in a descriptor list is private to the function to extract descriptor records from a
You specify the descriptor list that contains the desired descriptor records and an index as parameters to the AEGetNthPtr function. The index returns the data from the descriptor record represented by the specified index
.
You also specify the descriptor type the function should use to return the data,
a buffer to store the data, and the size of this buffer. The AEGetNthPtr function returns the keyword of the parameter, the descriptor type of the
returned data, and the actual size of the data, and it places the requested data in
the specified buffer.
Here's an example that uses the AEGetNthPtr function to extract an item Open Documents event.
myErr = AEGetNthPtr(& docList, index, typeFSS, &keywd, & returnedType, & myFSS, sizeof( myFSS), & actualSize);
the Open Documents event. The index variable specifies the index of the
descriptor record to extract. You can use the typeFSS descriptor type, as in
this example, to specify that the data be returned as a file system specification
original data type of the descriptor record from an alias record to a file system
specification record. The AEGetNthPtr function returns the keyword of the parameter in the keywd variable. The function returns in the returnedType
variable the descriptor type of the resulting data.
You specify a buffer to hold the desired data and the size (in bytes) of the
buffer as parameters to the AEGetNthPtr function. In this example, the myFSS variable specifies the buffer. The function returns the actual size of
the data in the actualSize variable. If this size is larger than the size of the
buffer you provided, you know that you didn't get all of the data for the
descriptor record.
The following program shows a more complete example of extracting the
// Extracting items from a descriptor list
// Assuming inclusion of
#include <AppleEvents.h>
void DoError (OSErr myErr); long index, itemsInList;
for ( index=1; index<= itemsInList; index++) {
& returnedType, (Ptr)& myFSS, sizeof( myFSS), & actualSize);
if ( myErr)
DoError( myErr);
myErr = MyOpenFile(& myFSS);
if ( myErr)
DoError( myErr);
}